﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Member.DbAccess;



namespace MvcHtmlDemo.Controllers
{
    public class LoginController : Controller
    {
        // GET: Login
        public ActionResult Index()
        {
            return Redirect("~/html/index.html");
        }

        [HttpGet]
        public ActionResult Query(string s)
        {
            //Request.QueryString
            return Redirect("~/html/index.html?s=" + s);
        }

        [HttpPost]
        public ActionResult In(string n, string p)
        {
            var dataAccess = new MemberDataAccess();
            var ds = dataAccess.QueryByName(n);
            bool isMath = false;

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {

                var pwd = ds.Tables[0].Rows[0]["Password"].ToString();
                if (pwd == p)
                {
                    isMath = true;
                }
            }
            
            return Content($"n={n}, p={p} 匹配：{isMath}");


        }

    }
}